$('table').ready(function() {
	$(this).find('tbody tr:odd').css('back-groundcolor');
})
$().ready(function() {
	$('.collapsed').click(function() {
		$this = $(this);
		if($this.hasClass('collapsed-yes')) {
			$(this).addClass('collapsed-no')
				.removeClass('collapsed-yes')
				.parent()
					.siblings()
					.show();
		} else {
			$(this).addClass('collapsed-yes')
				.removeClass('collapsed-no')
				.parent() 
					.siblings()
					.hide();
		}
		
	});
	$('#all-close').click(function() {
		$('.collapsed').removeClass('collapsed-yes').addClass('collapsed-no').click();
	})
	$('#all-open').click(function() {
		$('.collapsed').removeClass('collapsed-no').addClass('collapsed-yes').click();
	})
	
	$(':button[href], a.delete').live('click',function(e) {
		var linker = $(this);
		var href = linker.attr("href");
		var target = linker.attr("target");
		if(linker.hasClass('delete') || linker.hasClass('cancel')) {
			if(linker.hasClass('delete')) {
				var ask = linker.attr("ask") ? linker.attr("ask") : "确认删除这条记录吗";
			} else if(linker.hasClass('cancel')) {
				var ask = linker.attr("ask") ? linker.attr("ask") : "确认取消吗";
			}
			
			$.dialog.confirm(ask, function() {
				GetJump(href, target);
			});
			return false;
		} else {
			GetJump(href, target);
		}
	});
	
	$('#navigation li').mouseover(function() {
		$(this).addClass('sfHover');
	}).mouseout(function() {
		$(this).removeClass('sfHover');
	});
	
	$('.message .close').click(function() {
		$(this).parent().fadeOut('fast');
	}).mousemove(function() {
		$(this).addClass('hover');
	}).mouseout(function() {
		$(this).removeClass('hover');
	})
	
	$('#switch-screen').click(function() {
		if($(this).html() == '[切换窄版]') {
			width = '960px';
			style = '[切换宽版]'
		} else {
			width = '';
			style = '[切换窄版]';
		}
		$(this).html(style);
		$.cookie('screen-style', style, {expires: 999, path: '/'});
		$.cookie('screen-width', width, {expires: 999, path: '/'});
		$('#page, #header, #footer').css('width', width);
	})
	if($.cookie('screen-style')) {
		$('#switch-screen').html($.cookie('screen-style'));
		$('#page, #header, #footer').css('width', $.cookie('screen-width'));
	}
	
	$('.imglist li').mouseover(function() {
		$(this).children('ul').show();
	}).mouseout(function() {
		$(this).children('ul').hide();
	})
	
})

//跳转   
function GetJump(url, target) {   
	
	if (getIEVersion() > 0) { 
		var tempa = document.createElement("a");  
	    tempa.href = url;
	    if(target) tempa.target = target;
	    
	    document.getElementsByTagName("body")[0].appendChild(tempa);   
	    tempa.click();
	} else {
		if(target) {
			window.open(url,'dsadsa'); 
		} else {
			window.location.href = url;
		}
		
	}
}  
function getIEVersion() {   
    var rv = -1; // Return value assumes failure.     
    if (navigator.appName == "Microsoft Internet Explorer") {   
        var ua = navigator.userAgent;   
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");   
        if (re.exec(ua) != null)   
            rv = parseFloat(RegExp.$1);   
    }   
    return rv;   
} 

if($.fn.yiiactiveform) {
	$.fn.yiiactiveform.updateInput = function(attribute, messages, form) {
		attribute.status = 1;
		var hasError = messages!=null && $.isArray(messages[attribute.id]) && messages[attribute.id].length>0;
		var $error = $('#'+attribute.errorID, form);
		var $container = $.fn.yiiactiveform.getInputContainer(attribute, form);
		$container.removeClass(attribute.validatingCssClass)
			.removeClass(attribute.errorCssClass)
			.removeClass(attribute.successCssClass);
		
		var $input = $('#'+attribute.inputID, form)
		$input.removeClass('error');
		if(hasError) {
			$error.html(messages[attribute.id][0]);
			$container.addClass(attribute.errorCssClass);
			$input.addClass(attribute.errorCssClass);
		}
		else if(attribute.enableAjaxValidation || attribute.clientValidation) {
			$container.addClass(attribute.successCssClass);
			$input.addClass(attribute.successCssClass);
		}
		if(!attribute.hideErrorMessage)
			$error.toggle(hasError);
	
		attribute.value = $('#'+attribute.inputID, form).val();
		
		return hasError;
	};
}